import { ref } from 'vue'
import { defineStore } from 'pinia'
import { userLogin } from '@/apis/User'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref({})

  const login = async (data) => {
    let res = await userLogin(data)
    userInfo.value = res.data
  }
  //清除userInfon
  const layout = () => {
    userInfo.value = {}
  }
  return {
    userInfo,
    login,
    layout
  }
}, {
  persist: true  // 启用持久化存储
})
